package com.tarena.view;

import com.tarena.pojo.User;

import javax.swing.*;
import java.awt.*;

@SuppressWarnings({ "rawtypes", "serial" })
public class FriListCellRenderer extends JLabel implements ListCellRenderer {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        User user = (User)value;
        String name = user.getUsername();
        setText(name);
        ImageIcon icon = new ImageIcon(FriListCellRenderer.class.getClassLoader().getResource("qq.jpg").getPath());
        icon.setImage(icon.getImage().getScaledInstance(56, 56, Image.SCALE_DEFAULT));
        setIcon(icon);
        setIconTextGap(30);
        return this;
    }

}
